<?php
//Start de sessie
session_start();

// Database connection
include 'includes/connect.php';


if(!empty($_SESSION['winkelwagen']))
{
    echo '<h4>Winkelwagen</h4>';
	$total='0';
	foreach($_SESSION['winkelwagen'] as $key=>$value)
	{
	    $command = "SELECT * FROM product WHERE productid='$key'";
		$query2  = mysql_query($command) or die("SQL error: ".mysql_error());
		$row = mysql_fetch_array($query2);

        $now=mktime();
        if ($row['begindate'] < $now && $row['enddate'] > $now )
        {
            $price=$row['Promotieprijs'];
        }
        else
        {
            $price=$row['stdprijs'];
        }

            echo'<a href="product.php?id='.$row['productid'].'" title="'.$row['productnaam'].'">'.$row['productnaam'].'</a><br>
   				 '.$value.'x &euro;'.number_format($price,2).'
                <br><br>';
		$total += $value*$price;
	}
	echo "<br><br><p align='right'><b>Totaal: &euro; ".number_format($total,2)."<br></b><input type='button' onclick='window.location=\"view_cart.php\"' value='aanpassen'><input type='button' onclick='window.location=\"empty_cart.php\"' value='leegmaken'><input type='button' onclick='window.location=\"order.php\"' value='bestel'></p>";
}
else {
	include_once('temp/promo_filler.php');
}

?>